<?php

/**
 * This is the model class for table "event".
 *
 * The followings are the available columns in table 'event':
 * @property integer $E_id
 * @property string $E_title
 * @property string $E_subtitle
 * @property string $E_startdate
 * @property string $E_enddate
 * @property string $E_regstartdate
 * @property string $E_regenddate
 * @property string $E_multiparticipant
 * @property string $E_paidevent
 * @property integer $E_amount
 */
class Event extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Event the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'event';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('E_title, E_multiparticipant, E_paidevent', 'required'),
			array('E_id, E_amount', 'numerical', 'integerOnly'=>true),
			array('E_title, E_subtitle', 'length', 'max'=>30),
			array('E_multiparticipant, E_paidevent', 'length', 'max'=>1),
			array('E_startdate, E_enddate, E_regstartdate, E_regenddate', 'safe'),
			array('E_picture', 'file', 'types'=>'jpg, gif, png','allowEmpty'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('E_id, E_title, E_subtitle, E_startdate, E_enddate, E_regstartdate, E_regenddate, E_multiparticipant, E_paidevent, E_amount', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'E_id' => 'E',
			'E_title' => 'Title',
			'E_subtitle' => 'Subtitle',
			'E_startdate' => 'Event Start Date',
			'E_enddate' => 'Event End Date',
			'E_regstartdate' => 'Reg Start Date',
			'E_regenddate' => 'Reg End Date',
			'E_multiparticipant' => 'Group Registration Required ',
			'E_paidevent' => 'Paid Event',
			'E_amount' => 'Amount',
			'E_picture' => 'Picture',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('E_id',$this->E_id);
		$criteria->compare('E_title',$this->E_title,true);
		$criteria->compare('E_subtitle',$this->E_subtitle,true);
		$criteria->compare('E_startdate',$this->E_startdate,true);
		$criteria->compare('E_enddate',$this->E_enddate,true);
		$criteria->compare('E_regstartdate',$this->E_regstartdate,true);
		$criteria->compare('E_regenddate',$this->E_regenddate,true);
		$criteria->compare('E_multiparticipant',$this->E_multiparticipant,true);
		$criteria->compare('E_paidevent',$this->E_paidevent,true);
		$criteria->compare('E_amount',$this->E_amount);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}